import React, {Component} from 'react';
import {withRouter} from 'react-router-dom'
import './index.css'

class NavBar extends Component {

    render() {
        return (
            <div className={'nav-bar'}>
                <button onClick={this.goBack()}>﹤返回</button>
                <button onClick={this.goForward()}>前进﹥</button>
                <button onClick={this.go()}>go</button>
            </div>
        );
    }

    goBack = () => () => this.props.history.goBack()
    goForward = () => () => this.props.history.goForward()
    go = () => () => this.props.history.go(-2)
}

// withRouter 包装组件，让它有路由的特性
export default withRouter(NavBar);